package com.hzqy.web.ac.epg;


import com.hzqy.commons.utils.ExcelUtil;
import com.hzqy.commons.utils.ExcelUtil.MyEntry;
import com.hzqy.service.epg.AcSignService;
import com.hzqy.web.vo.AcWinningVo;
import com.hzqy.web.vo.epg.AcSignVo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/acSign")
public class AcSignAction {
    @Resource
	private AcSignService serviceAction;
    @RequestMapping("/acSignSelectAll")
	@ResponseBody
	public Object acSignSelect(AcSignVo asv, int page, int rows){
		Map<String,Object> SignListMap = new HashMap<String, Object>();
		SignListMap= serviceAction.selectAc(asv,page, rows);
		return SignListMap;
	}
	@RequestMapping("/acSignExcel")
	@ResponseBody
	public void acSignExcel(AcSignVo infoVo, HttpSession session, int page, int rows, HttpServletResponse response) throws IOException {
		Map<String,Object> ListMap = new HashMap<String, Object>();
    	ListMap = serviceAction.selectAc(infoVo,1,100000);
		List<AcWinningVo> data=(List<AcWinningVo>)ListMap.get("rows");
		List<MyEntry<String, String>> excelHeader=new ArrayList<MyEntry<String, String>>();
		excelHeader.add(new MyEntry<String,String>("f_asu_id","ID"));
		excelHeader.add(new MyEntry<String,String>("f_asu_serverid","业务帐号"));
		excelHeader.add(new MyEntry<String,String>("f_asu_activityid","活动编号"));
		excelHeader.add(new MyEntry<String,String>("f_asu_award","签到奖励"));
		excelHeader.add(new MyEntry<String,String>("f_asu_cdate","签到时间"));
		boolean flag= ExcelUtil.generateExcel(data, excelHeader, response);
	}

}
